﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace GenesisOne
{
    class Character
        : Sprite
    {
        int jumpt, maxIndex;
        bool lastMov;
        float index = 0;
        float speed, jumpSpeed, jumpHeight;
        Vector2 translation;

        public Character(Vector2 position, float speed, float jumpSpeed, float jumpHeight, Rectangle? sourceRectangle)
            : base(position, sourceRectangle)
        {
            this.speed = speed;
            this.jumpSpeed = jumpSpeed;
            this.jumpHeight = jumpHeight;
        }

        public Character(int x, int y, float speed, float jumpSpeed, float jumpHeight, Rectangle? sourceRectangle)
            : base(x, y, sourceRectangle)
        {
            this.speed = speed;
            this.jumpSpeed = jumpSpeed;
            this.jumpHeight = jumpHeight;
        }

        public Vector2 Translation
        {
            get { return translation; }
            set { this.translation = value; }
        }

        public int Jumpt
        {
            get { return jumpt; }
            set { this.jumpt = value; }
        }

        public int MaxIndex
        {
            get { return maxIndex; }
            set { this.maxIndex = value; }
        }

        public bool LastMov
        {
            get { return lastMov; }
            set { this.lastMov = value; }
        }
        
        public float Index
        {
            get { return index; }
            set { this.index = value; }
        }

        public float JumpSpeed
        {
            get { return jumpSpeed; }
            set { this.jumpSpeed = value; }
        }

        public float Speed
        {
            get { return speed; }
            set { this.speed = value; }
        }

        public float JumpHeight
        {
            get { return jumpHeight; }
            set { this.jumpHeight = value; }
        }

        public void LoadContent(ContentManager Content, string assetName, int maxIndex)
        {
            base.Texture = Content.Load<Texture2D>(assetName);
            this.maxIndex = maxIndex;
        }

        public void Update(GraphicsDeviceManager graphics, Map map, GameTime gameTime)
        {
            Physic.Gravity(this, graphics);
            SUpdate.Movement(this, graphics, map, gameTime);
            Physic.Jump(this);

            Position += translation;
            translation = new Vector2(0, translation.Y);
        }

    }
}
